﻿<!DOCTYPE html>

<html>
<head>
    <title>我的天联云</title>
    <link href="/SiteUI/Base.css" rel="stylesheet" />
    <link href="/LiberUI/Style/LiberUI.css" rel="stylesheet" />
    <link href="/SiteUI/Wechat/wechatBinding.css" rel="stylesheet" />
    <script src="/LiberUI/Scripts/jquery.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.Base.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.js"></script>
    <script src="/LiberUI/Scripts/LiberUI.Action.js"></script>
    <script src="/SiteUI/res_setting.js"></script>
</head>
<body>
    <script>
        SoBiz.Template("_wxBase");
    </script>
    <script type="text/html" section="PageBody">
        <div class="row">
            <div id="userHead-bg">
                <img id="headPortrait" src="/SiteUI/Imgs/logo-txt-little.png">
                <h3 id="userName"></h3>
            </div>
        </div>
        <div class="row details">
            <div class="col-lg-4">实名认证：</div>
            <div class="col-lg-4" id="realNameStatus">未认证</div>
            <span class="col-lg-4"><a id="realNameStatusLink" href="/WxPages/WxAcntCertify.html">申请认证</a></span>
        </div>
        <div class="row details">
            <div class="col-lg-4">手机号码：</div>
            <div class="col-lg-8" id="userPhone">-</div>
        </div>
        <div class="row details">
            <div class="col-lg-4">微信号：</div>
            <div class="col-lg-4" id="wechatState">未绑定</div>
            <span class="col-lg-4"><a id="wechatBind" href="#"></a></span>
        </div>
        <div class="row details">
            <div class="col-lg-4">我的企业：</div>
            <span class="col-lg-8"><a href="/WxPages/WxSetCompany.html">创建企业/加入企业</a></span>
        </div>
        <div class="row" id="myCompanys">

        </div>
    </script>
    <script>
        Index = {
            User: null,
            dlgConfirmUnbind: null,
            onUserReady: function (rtn) {
                $("#headPortrait").attr("src", User.headimg);
                $("#userPhone").vl(User.acnt);
                $("#userName").vl(User.username);
                switch (User.certifystatus) {
                    case "Pending": //审核中
                        $("#realNameStatus").vl("审核中");
                        $("#realNameStatusLink").remove();
                        break;
                    case "Aborted": //审核不通过
                        $("#realNameStatus").vl("未通过");
                        break;
                    case "Completed":  //审核通过
                        $(".People").removeClass("no-certificated").addClass("certificated");
                        $("#realNameStatus").vl("已认证");
                        $("#realNameStatusLink").remove();
                        break;
                }
                //微信
                Index.wechatCard();

                $.getJSON("/MyBiz/GetAcntAllCompanys", null, function (rtn) {
                    //构造用户相关公司列表
                });
            },
            wechatCard: function () {
                if (!User.wxuser) {
                    //无绑定
                    $("#wechatState").vl("还未绑定微信");
                }
                else {
                    //有绑定
                    $("#wechatState").vl(User.wxname);
                    $("#wechatBind").vl("解除绑定");
                    $("#wechatBind").on("click", function () {
                        //解除微信绑定
                        Index.dlgConfirmUnbind.update().show();
                    });
                }
            },
            wechatUnbind: function () {
                $.getJSON("/MyBiz/UnbindWechat", null, function () {
                    Index.dlgConfirmUnbind.hide();
                    window.location = "/WxPages/WxUserBinding.html?tm="+new Date().getTime().toString();
                });
            }
        }
        SoBiz.Ready(function () {
            Index.dlgConfirmUnbind = new LiberUI.Dialoger()
                                                .Title("取消绑定")
                                                .Content("绑定微信可以更加快捷方便的完成业务操作，及时得到重要业务通知，您确定要取消吗？")
                                                .BtnEnter("确定", "btn-lite", Index.wechatUnbind)
                                                .BtnEsc("取消", "");

            SoBiz.LoginWX(function () {
                $("#headPortrait").attr("src", WxUser.headimgurl);

                //尝试登录平台，失败转到注册绑定页面
                SoBiz.Login(Index.onUserReady, function () { window.location = "/WxPages/WxRegister.html?tm=" + new Date().getTime().toString(); });
            });
        })
    </script>
</body>

</html>
